<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改出库单')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-subinventoryTransferRecord-edit" th:object="${subinventoryTransferRecord}">
        <input id="transferId" name="transferId" th:field="*{transferId}"  type="hidden">
        <input th:field="*{forSubinventory}" type="hidden" id="hiddenForSubinventory">
        <input th:field="*{toSubinventory}" type="hidden" id="hiddenToSubinventory">

        <div class="form-group">
            <label class="col-sm-3 control-label">箱号：</label>
            <div class="col-sm-8">
                <input id="boxCode" name="boxCode" th:field="*{boxCode}" class="form-control" type="text">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">料号：</label>
            <div class="col-sm-8">
                <input id="itemCode" name="itemCode" th:field="*{itemCode}" class="form-control" type="text">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">物料描述：</label>
            <div class="col-sm-8">
                <input id="itemName" name="itemName" th:field="*{itemName}" class="form-control" type="text">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">批次：</label>
            <div class="col-sm-8">
                <input id="batch" name="batch" th:field="*{batch}" class="form-control" type="text">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">数量（张）：</label>
            <div class="col-sm-8">
                <input id="quantity" name="quantity" th:field="*{quantity}" class="form-control" type="text">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">转库人：</label>
            <div class="col-sm-8">
                <input id="operatorName" name="operatorName" th:field="*{operatorName}" class="form-control" type="text">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">转库人卡号：</label>
            <div class="col-sm-8">
                <input id="transferCardNo" name="transferCardNo" th:field="*{transferCardNo}" class="form-control" type="text">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">子库：</label>
            <div class="col-sm-8">
                <select id="forI" name="forI" class="form-control" >
                    <template v-for="(item, index) in rows" :key="index">
                        <option v-if="item.subInventoryId == forId" selected="selected" :value="item.subInventoryId">{{item.subInventoryName}}</option>
                        <option v-else :value="item.subInventoryId">{{item.subInventoryName}}</option>
                    </template>
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">目标子库：</label>
            <div class="col-sm-8">
                <select id="toI" name="toI" class="form-control" >
                    <template v-for="(item, index) in rows" :key="index">
                        <option v-if="item.subInventoryId == toId" selected="selected" :value="item.subInventoryId">{{item.subInventoryName}}</option>
                        <option v-else :value="item.subInventoryId">{{item.subInventoryName}}</option>
                    </template>
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">转移原因：</label>
            <div class="col-sm-8">
                <input id="transferMemo" name="transferMemo" th:field="*{transferMemo}" class="form-control" type="text">
            </div>
        </div>
    </form>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript">
    var prefix = ctx + "subinventoryTransferRecord";
    $("#form-subinventoryTransferRecord-edit").validate({
        rules:{
            xxxx:{
                required:true,
            },
        },
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-subinventoryTransferRecord-edit').serialize());
        }
    }

    var app = new Vue({
        el: '.wrapper',
        data: {
            rows: [],
            forId: '',
            toId: ''
        },
        created(){
            this.forId = document.querySelector('#hiddenForSubinventory').value;
            this.toId = document.querySelector('#hiddenToSubinventory').value;
            var that = this;
            $.ajax({
                cache : true,
                type: "POST",
                url: "/subInventory/list",
                data : {
                },
                dataType: "json",
                contentType: "application/json;charset-UTF-8",
                async : false,
                error : function(request) {
                    $.modal.alertError("系统错误");
                },
                success: function(res){
                    that.rows = res.rows;
                }
            })
        }
    })
</script>
</body>
</html>
